<?php
namespace Admin\Model;
use Think\Model;
class GoodsModel extends Model {
	public function getlist(){
		$page=I("p",1,"int");
		$info=$this->where('payment=1')->page($page.',25')->select();
		$count=$this->where('payment=1')->count();
		$Page=new\Think\Page($count,25);
		$Page->lastSuffix=false;
		$Page->setConfig('header','<div >共<span>%TOTAL_ROW%</span>条&nbsp;&nbsp;第<span>%NOW_PAGE%</span>页/共<span>%TOTAL_PAGE%</span>页&nbsp;&nbsp;每页25条</div>');
		$Page->setConfig('prev','');
		$Page->setConfig('next','');
		$Page->setConfig('theme','%HEADER% %FIRST%  %LINK_PAGE% %UP_PAGE% %DOWN_PAGE% %END% ');
		$show=$Page->show();
		return array("list"=>$info,"page"=>$show);
	}
	public function get_list1(){
		$search=I("account");
		if(!$search){
			$search=session('userphone');
		}else{
			session('userphone',$search);
		}
		$search=str_replace(' ', '', $search);
		$info1['user']=$search;
		$info1['payment']=1;
		$page=I("p",1,"int");
		$info=$this->where($info1)->page($page.',25')->select();
		$count=$this->where($info1)->count();
		$Page=new\Think\Page($count,25);
		$Page->lastSuffix=false;
		$Page->setConfig('header','<div >共<span>%TOTAL_ROW%</span>条&nbsp;&nbsp;第<span>%NOW_PAGE%</span>页/共<span>%TOTAL_PAGE%</span>页&nbsp;&nbsp;每页25条</div>');
		$Page->setConfig('prev','');
		$Page->setConfig('next','');
		$Page->setConfig('theme','%HEADER% %FIRST%  %LINK_PAGE% %UP_PAGE% %DOWN_PAGE% %END% ');
		$show=$Page->show();
		return array("list"=>$info,"page"=>$show);
	}

	public function get_phone(){
		$search=I("phone");
		$search=str_replace(' ', '', $search);
		$info1['phone']=$search;
		$info1['payment']=1;
		$info=$this->where($info1)->select();
		return array("list"=>$info);
	}

	public function upgoods($data){
		$data2['time']=date('Y-m-d',time());
		foreach ($data as $k => $v) {
			$data1['id']=$v['gid'];
			$data2['payment']=1;
			$this->where($data1)->save($data2);
		}
	}

	public function up_address(){//展示修改内容
		$data['id']=I('pk');
		$info=$this->where($data)->find();
		return $info;
	}

	public function up_address1(){//修改操作
		$data=I('post.');
		$id['id']=$data['pk'];
		$up['name']=$data['name'];
		$up['phone']=$data['phone'];
		$up['address']=$data['address'];
		$info=$this->where($id)->save($up);
		return $info;
	}
}